package tedu.study.ooday02_2;

import java.util.Objects;

public class Animal {
    String name;
    int age;
    String color;

    Animal(String name,int age,String color) {
        this.name = name;
        this.age = age;
        this.color = color;
    }

    void drink(){
        System.out.println(name+"在喝水");
    }

    void eat(){
        System.out.println(color+"色的"+age+"岁"+name+"在吃饭");
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Animal animal = (Animal) o;
        return age == animal.age && Objects.equals(name, animal.name) && Objects.equals(color, animal.color);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age, color);
    }
}
